package com.example.xlzx.controller;


import com.example.xlzx.entity.CaseAnalysis;
import com.example.xlzx.entity.Consultation;
import com.example.xlzx.result.Result;
import com.example.xlzx.service.ICaseAnalysisService;
import com.example.xlzx.service.IConsultationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 心理医生咨询表 前端控制器
 * </p>
 *
 * @author 1
 * @since 2025-03-07
 */
@RestController
@Tag(name="心理医生咨询信息")
@RequestMapping("/xlzx")
public class ConsultationController {
@Autowired
private IConsultationService iConsultationService;
    /**
     * 发送消息
     */
    @Operation(summary = "发送消息")
    @PostMapping("/send")
    public Result<String> sendMessage(@RequestBody Consultation message) {
        iConsultationService.sendMessage(message);
        return Result.ok("Message sent successfully");
    }

    /**
     * 获取聊天记录
     */
    @Operation(summary = "获取聊天记录")
    @GetMapping("/history")
    public Result<List<Consultation>> getChatHistory(
            @RequestParam Long senderId,
            @RequestParam Long receiverId) {
        List<Consultation> history = iConsultationService.getChatHistory(senderId, receiverId);
        return Result.ok(history);
    }

    /**
     * 获取实时消息
     */
    @Operation(summary = "获取实时消息")
    @GetMapping("/realtime")
    public Result<List<String>> getRealTimeMessages(
            @RequestParam Long senderId,
            @RequestParam Long receiverId) {
        List<String> messages = iConsultationService.getRealTimeMessages(senderId, receiverId);
        return Result.ok(messages);
    }


}
